using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using ShippingLiveSharpPackages;

namespace ShippingRemoteClient
{
    public partial class RemoteControl : UserControl
    {
        private TCPController controller;

        public RemoteControl()
        {
            InitializeComponent();
            controller = new TCPController();
        }

        public RemoteControl(RemoteTerminal terminal)
        {
            InitializeComponent();
            controller = new TCPController(terminal);
        }

        [Description("TCP Controller"), Editor()]
        public TCPController TCP
        {
            get
            {
                return controller;
            }
            set
            {
                controller = value;
            }
        }

        private void Logoff(object sender, EventArgs e)
        {
            this.controller.Logoff();
            RemoteLogin rml = new RemoteLogin();
            rml.TCP.Terminal = this.TCP.Terminal;
            this.Parent.Controls.Add(rml);
            CustomFunctions.FitFormToControl(rml, this.ParentForm);
            this.Parent.Controls.Remove(this);
        }

        private void Ping(object sender, EventArgs e)
        {
            this.controller.Ping();
        }

        private void Fetch(object sender, EventArgs e)
        {
            this.controller.RequestList();
        }
    }
}
